import dayjs from 'dayjs'


export function format(date: string | Date, fmt: string): string {
  return dayjs(date).format(fmt)
}


interface Preinstall {
  hasAll?: boolean;
  label?: string
}
const preinstall = {
  hasAll: false,
  label: 'name'
};
// 转换为筛选select options
export function formatOptions(
  targetList: Array<any>,
  { hasAll, label }: Preinstall = preinstall,
) {
  const filters = targetList.map((item: any) => ({
    label: item[label],
    value: item.id,
  }));
  
  if (hasAll) {
    filters.unshift({
      label: '全部',
      value: '',
    });
  }
  return filters;
}